/**
 * 
 */
package co.fitstart.entity.content.page;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 链接
 * 
 * @author Leo
 * @author lute
 */
@Entity
@Table(name="content_link")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class Link {

    @Id
    @GeneratedValue
    private Long id;
    
    /** 所在页面 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JSONField(serialize = false)
    private Webpage webpage;
    
    /** 链接ID */
    @JSONField(serialize = false)
    private String alias;
    
    /** 链接地址 */
    private String address;
    
    @JSONField(serialize = false)
    private Date createTime;
    
    @JSONField(serialize = false)
    private Date lastUpdateTime;

    @Column(name = "is_disabled")
    @JSONField(serialize = false)
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public Link() {

    }
    
    /**
     * edit link address
     * 
     * @param address
     * @return
     */
    public Link editAddress(String address) {
        this.address = address;
        this.lastUpdateTime = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the webpage
     */
    public Webpage getWebpage() {
        return webpage;
    }

    /**
     * @return the alias
     */
    public String getAlias() {
        return alias;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastUpdateTime
     */
    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param webpage the webpage to set
     */
    public void setWebpage(Webpage webpage) {
        this.webpage = webpage;
    }

    /**
     * @param alias the alias to set
     */
    public void setAlias(String alias) {
        this.alias = alias;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastUpdateTime the lastUpdateTime to set
     */
    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
